import service from '@/utils/request'

// 统一接口获取
export const getApi = (url: any,data: any) => {
    return service.post(url, data)
}

// 统一接口获取
export const postApi = (url: any,data: any,msg: any = '') => {
    // if (url == '/api/client/sms/code') {
    //     console.log(data);
    //     return new Promise((resolve) => {
    //         resolve({
    //             code: 200,
    //             data: {
    //                 cn: "发送成功",
    //                 en: "发送成功",
    //             }
    //         })
    //     })
    // }
    const headers: any = {
        loading: msg
    }
    return service.post(url, data, headers)
}

// 获取阿里云直传参数
export const getUploadToken = () => {
    return service.post('/api/direct_upload/upload_web_token')
}

// 获取阿里云直传参数
export const getDashboard = () => {
    return service.post('/api/main/home/dashboard')
}

// 配置信息列表
export const getSystemConfigList = (data: any) => {
    return service.post('/api/system/config/list', data)
}
// 设置配置信息
export const addSystemConfig = (data: any) => {
    return service.post('/api/system/config/set', data)
}
// 获取配置信息
export const getSystemConfig = (key: any) => {
    return service.post('/api/system/config/get/by/key', {key: key})
}
// 删除配置信息
export const delSystemConfig = (key: any) => {
    return service.post('/api/system/config/delete', {key: key})
}

// 阿里云直传oss参数配置获取-图片
export const getOssImage = (data: any) => {
    return service.post('/api/upload/oss/image/direct/policy', data)
}

// 阿里云直传oss参数配置获取-文件
export const getOssFile = (data: any) => {
    return service.post('/api/upload/oss/file/direct/policy', data)
}

// 获取供应商列表
export const getSupplierList = (data: any) => {
	return service.post('/api/strator/supplier/list', data)
}
// 新增-修改供应商
export const addSupplier = (data: any) => {
	return service.post(data.id ? '/api/strator/supplier/modify' : '/api/strator/supplier/add', data)
}
// 查看供应商详情
export const getSupplier = (id: number) => {
	return service.post('/api/strator/supplier/detail', {id})
}
// 获取客户列表
export const getCustomerList = (data: any) => {
	return service.post('/api/strator/customer/list', data)
}
// 新增-修改客户
export const addCustomer = (data: any) => {
	return service.post(data.id ? '/api/strator/customer/modify' : '/api/strator/customer/add', data)
}
// 查看客户详情
export const getCustomer = (id: number) => {
	return service.post('/api/strator/customer/detail', {id})
}
// 产品类型-开始
export const useProductTypeListApi = () => {
	return service.post('/api/strator/product/type/tree/all')
}

export const useProductTypeAddApi = (data: any) => {
	return service.post(data.id ? '/api/strator/product/type/modify' : '/api/strator/product/type/add', data)
}

export const useProductTypeApi = (data: any) => {
	return service.post('/api/strator/product/type/detail', data)
}
// 产品类型-结束
// 产品规格-开始
export const useProductSpecListApi = () => {
	return service.post('/api/strator/product/spec/tree/all')
}

export const useProductSpecAddApi = (data: any) => {
	return service.post(data.id ? '/api/strator/product/spec/modify' : '/api/strator/product/spec/add', data)
}

export const useProductSpecApi = (data: any) => {
	return service.post('/api/strator/product/spec/detail', data)
}
// 产品规格-结束
// 产品属性-开始
export const useProductAttrListApi = () => {
	return service.post('/api/strator/product/attr/tree/all')
}

export const useProductAttrAddApi = (data: any) => {
	return service.post(data.id ? '/api/strator/product/attr/modify' : '/api/strator/product/attr/add', data)
}

export const useProductAttrApi = (data: any) => {
	return service.post('/api/strator/product/attr/detail', data)
}
// 产品属性-结束
// 获取产品列表
export const getProductList = (data: any) => {
	return service.post('/api/strator/pro/list', data)
}
// 新增-修改产品
export const addProduct = (data: any) => {
	return service.post(data.id ? '/api/strator/pro/modify' : '/api/strator/pro/add', data)
}
// 查看所有产品
export const getProductListAll = (id: number) => {
	return service.post('/api/strator/pro/listall', {id})
}
// 查看产品详情
export const getProduct = (id: number) => {
	return service.post('/api/strator/pro/detail', {id})
}
// 获取产品sku列表
export const getProductSkuList = (data: any) => {
	return service.post('/api/strator/product/list', data)
}
// 获取产品批次列表
export const getBatchList = (data: any) => {
	return service.post('/api/strator/product/getBatchList', data ,{hideloading:true})
}
// 查看所有产品SKU
export const getProductSkuAll = (id: number) => {
	return service.post('/api/strator/product/listall', {id})
}
// 新增-修改sku产品
export const addProductSku = (data: any) => {
	return service.post(data.id ? '/api/strator/product/modify' : '/api/strator/product/add', data)
}
// 查看产品sku详情
export const getProductSku = (id: number) => {
	return service.post('/api/strator/product/detail', {id})
}
// 删除产品sku
export const delProductSku = (id: number) => {
	return service.post('/api/strator/product/delete', {id})
}
// 查看产品sku详情
export const getProductTotal = (data: any) => {
	return service.post('/api/strator/product/inventory/total', data)
}
// 导出产品库存信息
export const exportproduct = (data: any) => {
	return service.post('/api/strator/product/exportproduct', data)
}
// 获取出入库列表
export const getInventoryList = (data: any) => {
	return service.post('/api/strator/inventory/list', data)
}
// 新增-修改出入库单
export const addInventory = (data: any) => {
	return service.post(data.id ? '/api/strator/inventory/modify' : '/api/strator/inventory/add', data)
}
// 查看出入库单详情
export const getInventory = (id: number) => {
	return service.post('/api/strator/inventory/detail', {id})
}
// 查看出入库单详情
export const getInventoryItem = (data: any) => {
	return service.post('/api/strator/inventory/getItem', data)
}
// 导出出入库信息
export const exportinventory = (data: any) => {
	return service.post('/api/strator/inventory/exportinventory', data)
}
// 获取盘存列表
export const getCheckList = (data: any) => {
	return service.post('/api/strator/check/list', data)
}
// 新增-修改盘存单
export const addCheck = (data: any) => {
	return service.post(data.id ? '/api/strator/check/modify' : '/api/strator/check/add', data)
}
// 查看盘存单详情
export const getCheck = (id: number) => {
	return service.post('/api/strator/check/detail', {id})
}
// 查看盘存单详情
export const getCheckItem = (data: any) => {
	return service.post('/api/strator/check/getItem', data)
}
// 获取采购单列表
export const getPurchaseList = (data: any) => {
	return service.post('/api/strator/purchase/list', data)
}
// 新增-修改采购单
export const addPurchase = (data: any) => {
	return service.post(data.id ? '/api/strator/purchase/modify' : '/api/strator/purchase/add', data)
}
// 查看采购单详情
export const getPurchase = (id: number) => {
	return service.post('/api/strator/purchase/detail', {id})
}
// 查看采购单详情
export const getPurchaseItem = (data: any) => {
	return service.post('/api/strator/purchase/getItem', data)
}
// 查看采购单详情
export const getchecktime = (data: any) => {
	return service.post('/api/strator/check/getchecktime', data)
}
// 查看出入库单详情-根据IDS
export const getInventoryItemById = (data: any) => {
	return service.post('/api/strator/inventory/getItemById', data,{hideloading:true})
}